// house_pkg/pages/room/index.ts
Page({
  onLoad({
    point,
    building
  }) {
    this.fake(decodeURIComponent(point), decodeURIComponent(building))
  },
  fake(point, building) {
    // 508
    // 702
    const rooms = []
    // 表示有多少房间
    const size = wx.utils.getRandomIntInclusive(4, 8)
    for (let i = 0; i < size; i++) {
      // 楼层
      const floor = wx.utils.getRandomIntInclusive(1, 20)
      // 房间号码
      const no = wx.utils.getRandomIntInclusive(1, 9)
      // 整合成完整的房间号码
      const room = [floor, 0, no].join('')
      // 如果有重复的，就跳过这一次，开始下一次
      if (rooms.includes(room)) continue
      rooms.push(room)
    }
    this.setData({
      point, // 校区
      building, // 'x 号楼' or 'x 栋'
      rooms
    })
  },
  goForm(e) {
    const {
      point,
      building
    } = this.data
    wx.navigateTo({

      url: `/house_pkg/pages/form/index?point=${point}&building=${building}&room=${e.mark.room}`,
    })
  }
})